package com.example.tests;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import java.util.Set;

import org.testng.annotations.Test;

public class GroupModificationTests extends TestBase {
	
	@Test
	public void testFirstGroupCanBeRemoved() throws Exception {
		GroupObject validGroup = new GroupObject()
		.setName("rrrrrr").setHeader("ttttt").setFooter("yyyyyyyyyy");
		Set<GroupObject> oldList = app.getGroupHelper().getGroups();
		app.getGroupHelper().modifyGroup(0, validGroup);
		Set<GroupObject> newList = app.getGroupHelper().getGroups();
		verifyGroupAdded(oldList, validGroup, newList);
	}

	private void verifyGroupAdded(Set<GroupObject> oldList,
			GroupObject validGroup, Set<GroupObject> newList) {
			assertThat(newList.size(), equalTo(oldList.size()));
			validGroup.setId("$$$");
			oldList.add(validGroup);
			validGroup.setId("null");
			//Assert.assertEquals(newList.size(), oldList.size()+1);
			assertThat(newList, equalTo(oldList));
			
		}
}
